GtkStyleContext: Add gtk_style_context_get/set_scale
authorAlexander Larsson <alexl@redhat.com>
Thu, 27 Jun 2013 16:21:41 +0000 (18:21 +0200)
committerAlexander Larsson <alexl@redhat.com>
Wed, 3 Jul 2013 12:39:25 +0000 (14:39 +0200)
gtk/gtkstylecontext.c
gtk/gtkstylecontext.h

index 4a035e5d370d1446e1fe209b648fa037b1091f8b..f7f44ec5c615fe7c4a2a37e554d077c62835d0a1 100644 (file)
@@ -364,6 +364,7 @@ struct _GtkStyleContextPrivate
   GtkWidgetPath *widget_path;
   GHashTable *style_data;
   GtkStyleInfo *info;
+  gint scale;
 
   GdkFrameClock *frame_clock;
   guint frame_clock_update_id;
@@ -997,6 +998,7 @@ build_properties (GtkStyleContext      *context,
 
   _gtk_css_lookup_resolve (lookup, 
                            GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
+                          priv->scale,
                            values,
                            priv->parent ? style_data_lookup (priv->parent)->store : NULL);
 
@@ -1527,6 +1529,47 @@ gtk_style_context_get_state (GtkStyleContext *context)
   return context->priv->info->state_flags;
 }
 
+/**
+ * gtk_style_context_set_scale:
+ * @context: a #GtkStyleContext
+ * @scale: scale
+ *
+ * Sets the scale to use when getting image assets for the style .
+ *
+ * Since: 3.10
+ **/
+void
+gtk_style_context_set_scale (GtkStyleContext *context,
+                             gint             scale)
+{
+  g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
+
+  if (context->priv->scale == scale)
+    return;
+
+  context->priv->scale = scale;
+
+  gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_SOURCE);
+}
+
+/**
+ * gtk_style_context_get_scale:
+ * @context: a #GtkStyleContext
+ *
+ * Returns the scale used for assets.
+ *
+ * Returns: the scale
+ *
+ * Since: 3.10
+ **/
+gint
+gtk_style_context_get_scale (GtkStyleContext *context)
+{
+  g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0);
+
+  return context->priv->scale;
+}
+
 /**
  * gtk_style_context_state_is_running:
  * @context: a #GtkStyleContext
index 85ebf20ae90e4a1a630203e627a1d8bf1545fa24..ddc30a99f467362272a39993a2acc14429f762d0 100644 (file)
@@ -817,6 +817,12 @@ void          gtk_style_context_set_state    (GtkStyleContext *context,
 GDK_AVAILABLE_IN_ALL
 GtkStateFlags gtk_style_context_get_state    (GtkStyleContext *context);
 
+GDK_AVAILABLE_IN_3_10
+void          gtk_style_context_set_scale    (GtkStyleContext *context,
+                                              gint             scale);
+GDK_AVAILABLE_IN_3_10
+gint          gtk_style_context_get_scale    (GtkStyleContext *context);
+
 GDK_DEPRECATED_IN_3_6
 gboolean      gtk_style_context_state_is_running (GtkStyleContext *context,
                                                   GtkStateType     state,